home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / unzip.h < prev    next >
C/C++ Source or Header  |  1999-05-24  |  3KB  |  131 lines

  1. #ifndef __UNZIP_H
  2. #define __UNZIP_H
  3.  
  4. #include "osd_cpu.h"
  5. #include <stdio.h>
  6.  
  7. /***************************************************************************
  8.  * Support for retrieving files from zipfiles
  9.  ***************************************************************************/
  10.  
  11. struct zipent {
  12.     UINT32    cent_file_header_sig;
  13.     UINT8    version_made_by;
  14.     UINT8    host_os;
  15.     UINT8    version_needed_to_extract;
  16.     UINT8    os_needed_to_extract;
  17.     UINT16    general_purpose_bit_flag;
  18.     UINT16    compression_method;
  19.     UINT16    last_mod_file_time;
  20.     UINT16    last_mod_file_date;
  21.     UINT32    crc32;
  22.     UINT32    compressed_size;
  23.     UINT32    uncompressed_size;
  24.     UINT16    filename_length;
  25.     UINT16    extra_field_length;
  26.     UINT16    file_comment_length;
  27.     UINT16    disk_number_start;
  28.     UINT16    internal_file_attrib;
  29.     UINT32    external_file_attrib;
  30.     UINT32    offset_lcl_hdr_frm_frst_disk;
  31.     char*   name; /* 0 terminated */
  32. };
  33.  
  34. typedef struct _ZIP {
  35.     char* zip; /* zip name */
  36.     FILE* fp; /* zip handler */
  37.     long length; /* length of zip file */
  38.  
  39.     char* ecd; /* end_of_cent_dir data */
  40.     unsigned ecd_length; /* end_of_cent_dir length */
  41.  
  42.     char* cd; /* cent_dir data */
  43.  
  44.     unsigned cd_pos; /* position in cent_dir */
  45.  
  46.     struct zipent ent; /* buffer for readzip */
  47.  
  48.     /* end_of_cent_dir */
  49.     UINT32    end_of_cent_dir_sig;
  50.     UINT16    number_of_this_disk;
  51.     UINT16    number_of_disk_start_cent_dir;
  52.     UINT16    total_entries_cent_dir_this_disk;
  53.     UINT16    total_entries_cent_dir;
  54.     UINT32    size_of_cent_dir;
  55.     UINT32    offset_to_start_of_cent_dir;
  56.     UINT16    zipfile_comment_length;
  57.     char*    zipfile_comment; /* pointer in ecd */
  58. } ZIP;
  59.  
  60. /* Opens a zip stream for reading
  61.    return:
  62.      !=0 success, zip stream
  63.      ==0 error
  64. */
  65. ZIP* openzip(const char* path);
  66.  
  67. /* Closes a zip stream */
  68. void closezip(ZIP* zip);
  69.  
  70. /* Reads the current entry from a zip stream
  71.    in:
  72.      zip opened zip
  73.    return:
  74.      !=0 success
  75.      ==0 error
  76. */
  77. struct zipent* readzip(ZIP* zip);
  78.  
  79. /* Suspend access to a zip file (release file handler)
  80.    in:
  81.       zip opened zip
  82.    note:
  83.      A suspended zip is automatically reopened at first call of
  84.      readuncompressd() or readcompressed() functions
  85. */
  86. void suspendzip(ZIP* zip);
  87.  
  88. /* Resets a zip stream to the first entry
  89.    in:
  90.      zip opened zip
  91.    note:
  92.      ZIP file must be opened and not suspended
  93. */
  94. void rewindzip(ZIP* zip);
  95.  
  96. /* Read compressed data from a zip entry
  97.    in:
  98.      zip opened zip
  99.      ent entry to read
  100.    out:
  101.      data buffer for data, ent.compressed_size UINT8s allocated by the caller
  102.    return:
  103.      ==0 success
  104.      <0 error
  105. */
  106. int readcompresszip(ZIP* zip, struct zipent* ent, char* data);
  107.  
  108. /* Read decompressed data from a zip entry
  109.    in:
  110.      zip zip stream open
  111.      ent entry to read
  112.    out:
  113.      data buffer for data, ent.uncompressed_size UINT8s allocated by the caller
  114.    return:
  115.      ==0 success
  116.      <0 error
  117. */
  118. int readuncompresszip(ZIP* zip, struct zipent* ent, char* data);
  119.  
  120. /* public functions */
  121. int /* error */ load_zipped_file (const char *zipfile, const char *filename,
  122.     unsigned char **buf, unsigned int *length);
  123. int /* error */ checksum_zipped_file (const char *zipfile, const char *filename, unsigned int *length, unsigned int *sum);
  124.  
  125. void unzip_cache_clear(void);
  126.  
  127. /* public globals */
  128. extern int    gUnzipQuiet;    /* flag controls error messages */
  129.  
  130. #endif
  131.